package com.example.demo.controller;

import com.example.demo.entity.TableProduct;
import com.example.demo.entity.Users;
import com.example.demo.entity.UsersDto;
import com.example.demo.service.ProductService;
import com.example.demo.service.UserService;
import com.example.demo.utils.PageDataList;
import com.example.demo.utils.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product")
public class ProductController {



    @Autowired
    private ProductService productService;//ProductService productService = new ProductService();


    @PostMapping("/list")
    public ResultUtil getList(@RequestBody TableProduct users) {
        PageDataList<TableProduct> resultList = productService.getList(users);
        ResultUtil resultUtil = new ResultUtil();
        if (resultList != null) {
            resultUtil.setResultCode("200");
            resultUtil.setResultMsg("请求成功");
            resultUtil.setResultData(resultList);
        } else {
            resultUtil.setResultCode("201");
            resultUtil.setResultMsg("请求失败");
        }
        return resultUtil;
    }
}
